﻿/*
 * Microsoft .NET  2.0+ version of Sphinx searchd client (Sphinx API)
 * 
 * Copyright (c) 2009, Shaun Berryman
 * All rights reserved
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License. You should have
 * received a copy of the GPL license along with this program; if you
 * did not, you can find it at http://www.gnu.org/
 */

using System;
using System.Collections.Generic;
using System.Text;

namespace SphinxSearchApi
{
    /// <summary>
    /// Wrapper around SphinxClient. Simply opens a persistent connection and
    /// implements IDisposable which will close the connection on dispose.
    /// </summary>
    public class SphinxClientPersistent : SphinxClient, IDisposable
    {
        /// <summary>
        /// Creates new SphinxClient instance; will also open the connection
        /// 
        /// Will set host and port to localhost:3312
        /// </summary>
        public SphinxClientPersistent() : base()
        {
            base.Open();
        }

        /// <summary>
        /// Creates new SphinxClient instance; will also open the connection
        /// </summary>
        /// <param name="host">Hostname/IP address of the sphinx server</param>
        /// <param name="port">Port number of the instance. Default value is 3312</param>
        public SphinxClientPersistent(string host, int port) : base(host, port)
        {
            base.Open();
        }

        #region IDisposable Members

        public void Dispose()
        {
            base.Close();
        }

        #endregion
    }
}
